<?php
namespace app\admin\controller;
use think\Controller;
use think\Request;
class Common extends Controller
{

    //初始化 
    public function _initialize()
    {
        if(!session('id') || !session('name')){
            $this->error('你尚未登录，请登录！',url('admin/login/index'));
        }

        $auth=new Auth();
        $request=Request::instance();
        $conf=$request->controller();
        $action=$request->action();
        $name=$conf.'/'.$action;
        $notCheck=array('Index/index','Admin/lst','Admin/loginout');
        if(session('id') !=1){

            if(!in_array($name,$notCheck)){
                if(!$auth->check($name,session('id'))){
                    $this->error('没有权限',url('index/index'));
                }
            }
            
        }
        
    }
   
}
